<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    
    <title>numpy.logaddexp2 &mdash; NumPy v1.18 Manual</title>
    
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-bootstrap.css">
    <link rel="stylesheet" type="text/css" href="../../_static/css/spc-extend.css">
    <link rel="stylesheet" href="../../_static/scipy.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" >
    <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" >
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '1.18.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  false
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <script type="text/javascript" src="../../_static/js/copybutton.js"></script>
    <link rel="author" title="About these documents" href="../../about.html" >
    <link rel="index" title="Index" href="../../genindex.html" >
    <link rel="search" title="Search" href="../../search.html" >
    <link rel="top" title="NumPy v1.18 Manual" href="../../index.html" >
    <link rel="up" title="Mathematical functions" href="../routines.math.html" >
    <link rel="next" title="numpy.i0" href="numpy.i0.html" >
    <link rel="prev" title="numpy.logaddexp" href="numpy.logaddexp.html" > 
  </head>
  <body>
<div class="container">
  <div class="top-scipy-org-logo-header" style="background-color: #a2bae8;">
    <a href="../../index.html">
      <img border=0 alt="NumPy" src="../../_static/numpy_logo.png"></a>
    </div>
  </div>
</div>


    <div class="container">
      <div class="main">
        
	<div class="row-fluid">
	  <div class="span12">
	    <div class="spc-navbar">
              
    <ul class="nav nav-pills pull-left">
        <li class="active"><a href="https://numpy.org/">NumPy.org</a></li>
        <li class="active"><a href="https://numpy.org/doc">Docs</a></li>
        
        <li class="active"><a href="../../index.html">NumPy v1.18 Manual</a></li>
        

          <li class="active"><a href="../index.html" >NumPy Reference</a></li>
          <li class="active"><a href="../routines.html" >Routines</a></li>
          <li class="active"><a href="../routines.math.html" accesskey="U">Mathematical functions</a></li> 
    </ul>
              
              
    <ul class="nav nav-pills pull-right">
      <li class="active">
        <a href="../../genindex.html" title="General Index"
           accesskey="I">index</a>
      </li>
      <li class="active">
        <a href="numpy.i0.html" title="numpy.i0"
           accesskey="N">next</a>
      </li>
      <li class="active">
        <a href="numpy.logaddexp.html" title="numpy.logaddexp"
           accesskey="P">previous</a>
      </li>
    </ul>
              
	    </div>
	  </div>
	</div>
        

	<div class="row-fluid">
      <div class="spc-rightsidebar span3">
        <div class="sphinxsidebarwrapper">
  <h4>Previous topic</h4>
  <p class="topless"><a href="numpy.logaddexp.html"
                        title="previous chapter">numpy.logaddexp</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="numpy.i0.html"
                        title="next chapter">numpy.i0</a></p>
<div id="searchbox" style="display: none" role="search">
  <h4>Quick search</h4>
    <div>
    <form class="search" action="../../search.html" method="get">
      <input type="text" style="width: inherit;" name="q" />
      <input type="submit" value="search" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
          <div class="span9">
            
        <div class="bodywrapper">
          <div class="body" id="spc-section-body">
            
  <div class="section" id="numpy-logaddexp2">
<h1>numpy.logaddexp2<a class="headerlink" href="#numpy-logaddexp2" title="Permalink to this headline">¶</a></h1>
<dl class="data">
<dt id="numpy.logaddexp2">
<code class="sig-prename descclassname">numpy.</code><code class="sig-name descname">logaddexp2</code><span class="sig-paren">(</span><em class="sig-param">x1</em>, <em class="sig-param">x2</em>, <em class="sig-param">/</em>, <em class="sig-param">out=None</em>, <em class="sig-param">*</em>, <em class="sig-param">where=True</em>, <em class="sig-param">casting='same_kind'</em>, <em class="sig-param">order='K'</em>, <em class="sig-param">dtype=None</em>, <em class="sig-param">subok=True</em><span class="optional">[</span>, <em class="sig-param">signature</em>, <em class="sig-param">extobj</em><span class="optional">]</span><span class="sig-paren">)</span><em class="property"> = &lt;ufunc 'logaddexp2'&gt;</em><a class="headerlink" href="#numpy.logaddexp2" title="Permalink to this definition">¶</a></dt>
<dd><p>Logarithm of the sum of exponentiations of the inputs in base-2.</p>
<p>Calculates <code class="docutils literal notranslate"><span class="pre">log2(2**x1</span> <span class="pre">+</span> <span class="pre">2**x2)</span></code>. This function is useful in machine
learning when the calculated probabilities of events may be so small as
to exceed the range of normal floating point numbers.  In such cases
the base-2 logarithm of the calculated probability can be used instead.
This function allows adding probabilities stored in such a fashion.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>x1, x2</strong><span class="classifier">array_like</span></dt><dd><p>Input values. If <code class="docutils literal notranslate"><span class="pre">x1.shape</span> <span class="pre">!=</span> <span class="pre">x2.shape</span></code>, they must be broadcastable to a common shape (which becomes the shape of the output).</p>
</dd>
<dt><strong>out</strong><span class="classifier">ndarray, None, or tuple of ndarray and None, optional</span></dt><dd><p>A location into which the result is stored. If provided, it must have
a shape that the inputs broadcast to. If not provided or None,
a freshly-allocated array is returned. A tuple (possible only as a
keyword argument) must have length equal to the number of outputs.</p>
</dd>
<dt><strong>where</strong><span class="classifier">array_like, optional</span></dt><dd><p>This condition is broadcast over the input. At locations where the
condition is True, the <em class="xref py py-obj">out</em> array will be set to the ufunc result.
Elsewhere, the <em class="xref py py-obj">out</em> array will retain its original value.
Note that if an uninitialized <em class="xref py py-obj">out</em> array is created via the default
<code class="docutils literal notranslate"><span class="pre">out=None</span></code>, locations within it where the condition is False will
remain uninitialized.</p>
</dd>
<dt><strong>**kwargs</strong></dt><dd><p>For other keyword-only arguments, see the
<a class="reference internal" href="../ufuncs.html#ufuncs-kwargs"><span class="std std-ref">ufunc docs</span></a>.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>result</strong><span class="classifier">ndarray</span></dt><dd><p>Base-2 logarithm of <code class="docutils literal notranslate"><span class="pre">2**x1</span> <span class="pre">+</span> <span class="pre">2**x2</span></code>.
This is a scalar if both <em class="xref py py-obj">x1</em> and <em class="xref py py-obj">x2</em> are scalars.</p>
</dd>
</dl>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<dl class="simple">
<dt><a class="reference internal" href="numpy.logaddexp.html#numpy.logaddexp" title="numpy.logaddexp"><code class="xref py py-obj docutils literal notranslate"><span class="pre">logaddexp</span></code></a></dt><dd><p>Logarithm of the sum of exponentiations of the inputs.</p>
</dd>
</dl>
</div>
<p class="rubric">Notes</p>
<div class="versionadded">
<p><span class="versionmodified added">New in version 1.3.0.</span></p>
</div>
<p class="rubric">Examples</p>
<div class="doctest highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">prob1</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log2</span><span class="p">(</span><span class="mf">1e-50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prob2</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">log2</span><span class="p">(</span><span class="mf">2.5e-50</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prob12</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">logaddexp2</span><span class="p">(</span><span class="n">prob1</span><span class="p">,</span> <span class="n">prob2</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">prob1</span><span class="p">,</span> <span class="n">prob2</span><span class="p">,</span> <span class="n">prob12</span>
<span class="go">(-166.09640474436813, -164.77447664948076, -164.28904982231052)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="mi">2</span><span class="o">**</span><span class="n">prob12</span>
<span class="go">3.4999999999999914e-50</span>
</pre></div>
</div>
</dd></dl>

</div>


          </div>
        </div>
          </div>
        </div>
      </div>
    </div>

    <div class="container container-navbar-bottom">
      <div class="spc-navbar">
        
      </div>
    </div>
    <div class="container">
    <div class="footer">
    <div class="row-fluid">
    <ul class="inline pull-left">
      <li>
        &copy; Copyright 2008-2019, The SciPy community.
      </li>
      <li>
      Last updated on Feb 20, 2020.
      </li>
      <li>
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 2.4.2.
      </li>
    </ul>
    </div>
    </div>
    </div>
  </body>
</html>